package com.view.cn.mvprxjava.adapter;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.view.View;
import android.view.ViewGroup;

import com.view.cn.mvprxjava.R;

import java.util.List;

/**
 * ListView数据展示
 * Created by zxp19920626 on 2016/4/27.
 */
public class ListRcvAdapter extends BaseRcvAdapter<BaseViewHolder> {

	public ListRcvAdapter(Context context, List<Object> mList) {
		super(context, mList);
	}

	public ListRcvAdapter(Fragment fragment, List<Object> mList) {
		super(fragment, mList);
	}

	@Override
	public BaseViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
		View view = mLayoutInflater.inflate(R.layout.item_list, parent, false);
		return new BaseViewHolder(context, view);
	}

	@Override
	public void onBindViewHolder(BaseViewHolder holder, final int position) {
		super.onBindViewHolder(holder, position);
		holder.setText(R.id.tv, mList.get(position).toString())
				.setText(R.id.delete, "");
		//编辑模式
		holder.views.get(R.id.delete).setVisibility(isEdit ? View.VISIBLE : View.GONE);
		//点击事件
		holder.views.get(R.id.delete).setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				remove(position);
			}
		});
	}
}
